<template>
    <div>
        <el-form-item label="用户名">
            <el-input v-model="username" />
        </el-form-item>
        <el-form-item label="密码">
            <el-input v-model="password" />
        </el-form-item>
        <el-button type="primary" @click="registerIn">注册</el-button>
    </div>
</template>

<script setup>
import { register } from "@/api/user";
import { ElMessage } from 'element-plus'
import { ref } from "vue";
import { useRouter } from "vue-router";
const router = useRouter();
const username = ref("hbz");
const password = ref("123465");
const registerIn = () => {
    register({
        username: username.value,
        password: password.value
    }).then(res => {
        if(res.code == 200) {
            ElMessage.success("注册成功")
            router.push({
                path: "/login",
                query: {
                    username: username.value,
                    password: password.value
                }
            })
        }
    })
}
</script>